home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 May
/
EnigmA AMIGA RUN 18 (1997)(G.R. Edizioni)(IT)[!][issue 1997-05][EAR-CD II].iso
/
earcd
/
dev
/
amos
/
blox0_7.lha
/
score
/
score.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1980-09-18
|
4KB
|
212 lines
'
' amospro high score routine
'
'
Dim NOM$(9),SCORE(9)
Global NOM$(),SCORE()
'
'
' Small example
'
' Close screen 0 (default)
' Screen Close 0
'
' Load a list of scores from "Hiscores.SCR"
HISCORE_LOAD["Hiscores.SCR"]
'
HISCORE_ENTER[Val(Command Line$)]
'
' Save the new table on the disc
HISCORE_SAVE["Hiscores.SCR"]
'
Timer=0
JW:
A=Joy(1)
If Timer>250 Then Command Line$=Str$(SCORE(0)) : Run "blox"
If A>15 Then Goto JW2
Goto JW
JW2:
'
' Finally, remove the hi-score table from the screen
HISCORE_REMOVE
'
Command Line$=Str$(SCORE(0))
Run "blox"
'
'F9 (Fold/Unfold) displays the full listings
Procedure HISCORE_DISPLAY
'
Global SCR_FLG
'
Dim C(16)
'
' Unpack the image into screen 7, and fade it down to black
Unpack 10 To 7 : Screen Hide
For C=0 To 15 : C(C)=Colour(C) : Colour C,0 : Next
'
' This internal flag is set to one if we have to
' enter the name. In this case, we just copy the
' ENTER YOUR NAME picture to the title area at the top of the screen
If SCR_FLG
Screen Copy 7,80,72,240,120 To 7,80,8
End If
'
' Erase 'Enter your name' from the screen area
Cls 0,80,72 To 240,120
'
' Display the 10 names using a FOR..NEXT loop
'
Ink 1,0,0
For I=0 To 9
YP=82+I*9
SCORE$=Mid$(Str$(SCORE(I)),2)
LS=Text Length(SCORE$)
Text 85,YP,NOM$(I)
Text 251-LS,YP,SCORE$
Next I
'
' Now we can fade in the screen
Screen Show
'
' Fade the screen back to the original colours
Fade 1,C(0),C(1),C(2),C(3),C(4),C(5),C(6),C(7),C(8),C(9),C(10),C(11),C(12),C(13),C(14),C(15)
' Wait until the fade is over
Wait 16
'
Pop Proc
'
End Proc
Procedure HISCORE_REMOVE
'
' Simply fade out the screen to black, and erase it
Fade 1 : Wait 16
Screen Close 7
'
End Proc
Procedure HISCORE_ENTER[SCORE]
'
Global SCR_FLG
'
If SCORE>SCORE(9)
'
' Find the position of our new score in the table
POS=0
While SCORE<=SCORE(POS)
POS=POS+1
Wend
' Move the lower scores one place down
For I=9 To POS+1 Step -1
NOM$(I)=NOM$(I-1)
SCORE(I)=SCORE(I-1)
Next I
NOM$(POS)=""
SCORE(POS)=SCORE
'
' Display score, with the ENTER YOUR NAME picture along the title
SCR_FLG=-1 : HISCORE_DISPLAY
'
' Set up Cursor
Flash 15,"(FFF,30)(666,20)"
XC=100 : YC=50
'
' Display Cursor
Gosub CURSEUR
'
' Input the name using a REPEAT..UNTIL loop
Repeat
' Read keyboard
K$=Inkey$
K=Asc(K$)
L=Len(NOM$)
' Handle Backspace
If K=8 and L>0
DC=0
XC=XC-8
Text XC,YC," "
Gosub CURSEUR
NOM$=Left$(NOM$,L-1)
End If
' Handle cursor
If K>13 and L<12
DC=8
Ink 1 : Text XC,YC,K$
XC=XC+8
Gosub CURSEUR
NOM$=NOM$+K$
End If
'
' Repeat until a carriage return.
Until K=13
'
' Put the new name into the NOM$ array
NOM$(POS)=NOM$
SCORE(POS)=SCORE
'
' Erase screen
Flash Off
HISCORE_REMOVE
SCR_FLG=0
'
End If
'
' Display final array, and return!
HISCORE_DISPLAY
'
Pop Proc
'
' Simulate a 'fake' text cursor using the DRAW command
CURSEUR:
Ink 15 : Draw XC,YC+1 To XC+6,YC+1
Return
'
End Proc
Procedure HISCORE_LOAD[N$]
'
' Handle errors
On Error Goto ERREUR
'
' Open a simple sequential file
Open In 1,N$
' Read the names and scores from the disc
For I=0 To 9
Line Input #1,NOM$(I),SCORE$
SCORE(I)=Val(SCORE$)
Next I
' Close up the file
Close 1
'
SKIP:
Pop Proc
'
ERREUR:
Resume SKIP
'
End Proc
Procedure HISCORE_SAVE[N$]
'
' Handle errors
On Error Goto ERREUR
'
' Create a simple sequential file
Open Out 1,N$
' Write the names and scores to the new file
For I=0 To 9
Print #1,NOM$(I)
Print #1,Str$(SCORE(I))
Next I
' Close the file (ESSENTIAL!)
Close 1
'
SKIP:
Pop Proc
'
ERREUR:
Resume SKIP
'
End Proc